<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>零件信息表</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
    <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css"></link>
    <script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.js"></script>
    <style type="text/css">
        .swfupload {
            left: 12px;
        }

        .uploadify {
            margin: 5px;
            margin-right: 20px;
        }

        #file_upload {
            float: right;
        }

        .imgDiv {
            width: 90px;
            height: 115px;
            display: inline-block;
            text-align: center;
            margin: 5px;
        }
    </style>
</head>
<body>

<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table"
             action="cbsPartInfoController.do?doUpdate" tiptype="3">

    <input id="id" name="id" type="hidden" value="${cbsPartInfoPage.id }">
    <input id="createName" name="createName" type="hidden" value="${cbsPartInfoPage.createName }">
    <input id="createBy" name="createBy" type="hidden" value="${cbsPartInfoPage.createBy }">
    <input id="createDate" name="createDate" type="hidden" value="${cbsPartInfoPage.createDate }">
    <input id="updateName" name="updateName" type="hidden" value="${cbsPartInfoPage.updateName }">
    <input id="updateBy" name="updateBy" type="hidden" value="${cbsPartInfoPage.updateBy }">
    <input id="updateDate" name="updateDate" type="hidden" value="${cbsPartInfoPage.updateDate }">
    <div class="subtitle">
        <p>零件信息</p>
        <table class="nobordertable noborder">
            <tr>
                <td class="al_r" width="20%"><label>零件号:</label></td>
                <td width="20%"><input type="text" name="partNo" id="partNo" datatype="*2-20"
                                       style="width: 150px" class="inputxt" value="${cbsPartInfoPage.partNo }"/></td>
                <td class="al_r" width="30%"><label>英文描述：</label></td>
                <td><input type="text" name="englishDes" id="englishDes"
                           style="width: 150px" class="inputxt" value="${cbsPartInfoPage.englishDes }"></td>
            </tr>
            <tr>
                <td class="al_r" width="20%"><label>中文描述:</label></td>
                <td width="20%"><input type="text" name="chineseDes"
                                       id="chineseDes" style="width: 150px" class="inputxt"
                                       value="${cbsPartInfoPage.chineseDes }"/></td>
                <td class="al_r" width="30%"><label>销售单位：</label></td>
                <td>
                    <t:dictSelect field="marketUnit" typeGroupCode="<%=StaticValue.DIC_MARKET_UNIT %>"
                                  defaultVal="${cbsPartInfoPage.marketUnit }"/>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%"><label>微信推广名:</label></td>
                <td width="20%"><input type="text" name="wechatName"
                                       id="wechatName" style="width: 150px" class="inputxt"
                                       value="${cbsPartInfoPage.wechatName }"/></td>
                <td class="al_r" width="30%"><label>所属商品分类：</label></td>
                <td>
                    <t:dictSelect field="commodity" typeGroupCode="<%=StaticValue.CLASSIFY %>"
                                  defaultVal="${cbsPartInfoPage.commodity }"/>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%"><label>适用机型:</label></td>
                <td width="20%"><input type="text" name="type"
                                       id="type" style="width: 150px" class="inputxt" value="${cbsPartInfoPage.type }"/>
                </td>
                <td class="al_r" width="20%"><label>是否可售:</label></td>
                <td class="30%">
                    <t:dictSelect field="canSale" defaultVal="${cbsPartInfoPage.canSale}"
                                  typeGroupCode="trueOfFlaseNum"/>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%"><label>是否微信可售:</label></td>
                <td class="30%">
                    <t:dictSelect field="canWxSale" defaultVal="${cbsPartInfoPage.canWxSale}" typeGroupCode="trueOfFlaseNum"/>
                </td>
                <td class="al_r" width="20%"><label></label></td>
                <td width="20%"></td>
            </tr>
            <tr>
                <td class="al_r" width="20%"><label>详细说明:</label></td>
                <td class="90%" colspan="3">
                    <textarea style="width:90%;" class="inputxt" rows="3" id="details"
                              name="details">${cbsPartInfoPage.details }</textarea>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">图片：</td>
                <td colspan="3" rowspan="2" id="imgTd">
                    <c:forEach items="${cbsPartInfoPage.partImgList }" var="img">
                        <div class="imgDiv">
                            <input type="hidden" value="${img.allPath }" name="filePathStr">
                            <input type="hidden" value="${img.filename }" name="fileNameStr">
                            <input type="hidden" value="${img.filerealname }" name="fileRealNameStr">
                            <img src="cbsPartInfoController.do?downLoadFile&filePath=${img.allPath }" height="90"
                                 width="90">
                            <br>
                            <a href="#" onclick="delImg(this)">删除</a>
                        </div>
                    </c:forEach>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%"><span style='' id='file_upload'></span></td>
            </tr>
        </table>

    </div>
    <div class="subtitle">
        <table align="center" style="margin-top: 20px; line-height: 50px; width: 80%;" cellpadding="0" cellspacing="1"
               class="formtable">
            <tr>
                <td width="20%" align="center">终端价</td>
                <td width="30%" align="center" style="background-color: #FFFFFF;">
                    <input type="text" name="terminalPrice" value="${cbsPartInfoPage.terminalPrice }" dataType="nPn"
                           style="width:200px;"/>
                </td>
            </tr>
            <tr>
                <td width="20%" align="center">中影优惠价</td>
                <td width="30%" align="center" style="background-color: #FFFFFF;">
                    <input type="text" name="cfgcPrice" value="${cbsPartInfoPage.cfgcPrice }" dataType="nPn"
                           style="width:200px;"/>
                </td>
            </tr>
            <tr>
                <td width="20%" align="center">横店优惠价</td>
                <td width="30%" align="center" style="background-color: #FFFFFF;">
                    <input type="text" name="hdPrice" value="${cbsPartInfoPage.hdPrice }" dataType="nPn"
                           style="width:200px;"/>
                </td>
            </tr>
            <c:if test="${cbsPartInfoPage.commodity == 'consumable'}">
                <tr class="cinemaPriceTr">
                    <td width="20%" align="center">院线价</td>
                    <td width="30%" align="center" style="background-color: #FFFFFF;">
                        <input type="text" name="cinemaPrice" value="${cbsPartInfoPage.cinemaPrice }" dataType="nPn"
                               style="width:200px;"/>
                    </td>
                </tr>
            </c:if>
            <tr>
                <td width="20%" align="center">微信优惠价</td>
                <td width="30%" align="center" style="background-color: #FFFFFF;">
                    <input type="text" name="wechatPrice" value="${cbsPartInfoPage.wechatPrice }" dataType="nPn"
                           style="width:200px;"/>
                </td>
            </tr>
        </table>
    </div>
</t:formvalid>
</body>
<script type="text/javascript">
    $(function () {
        loadUploadify("file_upload");
        $("select[name='commodity']").attr("disabled", true);
        /*$("select[name='sort']").change(function(){
         if($(this).find("option:selected").val() == 'consumable'){
         $(".cinemaPriceTr").show();
         $("input[name='cinemaPrice']").attr("dataType","lessThanInput");
         $("input[name='cinemaPrice']").attr("with","terminalPrice");
         //            dataType="lessThanInput" with="terminalPrice"
         }else{
         $(".cinemaPriceTr").hide();
         $("input[name='cinemaPrice']").removeAttr("dataType");
         $("input[name='cinemaPrice']").removeAttr("with");
         }
         })*/
    })

    function delImg(del) {
        $(del).parent().remove();
    }

    function loadUploadify() {
        $("#file_upload").uploadify({
            buttonText: '添加',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 25,
            width: 60,
            buttonClass: 'uploadFileBtn',
            overrideEvents: ['onDialogClose'],
            fileTypeDesc: '文件格式:',
            queueID: 'instructionfile',
            fileTypeExts: '*.jpg;*.png;',
            fileSizeLimit: '15MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: 'cbsPartInfoController.do?saveImgFiles&sessionId=${sessionId}',
            onUploadStart: function (file) {
                var documentTitle = $('#documentTitle').val();
                $('#file_upload').uploadify("settings",
                        "formData",
                        {'documentTitle': documentTitle});
            },
            onQueueComplete: function (queueData) {
            },
            onUploadSuccess: function (file, data, response) {
                var data = $.parseJSON(data);
                var appStr = '<div class="imgDiv">';
                appStr += '<input type="hidden" value="' + data.filePath + '" name="filePathStr">';
                appStr += '<input type="hidden" value="' + data.fileName + '" name="fileNameStr">';
                appStr += '<input type="hidden" value="' + data.fileRealName + '" name="fileRealNameStr">';
                appStr += '<img src="cbsPartInfoController.do?downLoadFile&filePath=' + data.filePath + '" height="90" width="90">';
                appStr += '<br><a href="#" onclick="delImg(this)">删除</a>';
                appStr += '</div>';
                $('#imgTd').append(appStr);
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试")
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的" + $('#instruction').uploadify('settings', 'fileSizeLimit') + "大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }, onUploadProgress: function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
            }
        });
    }
</script>